package com.tiocloud.session.feature.join_group_apply_info;

import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.StringUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tiocloud.session.R;
import com.tiocloud.session.TioSession;
import com.watayouxiang.androidutils.widget.imageview.TioImageView;
import com.watayouxiang.httpclient.model.response.GroupApplyInfoResp;

/**
 * <pre>
 *     author : TaoWang
 *     e-mail : watayouxiang@qq.com
 *     time   : 2021/02/09
 *     desc   :
 * </pre>
 */
class ListAdapter extends BaseQuickAdapter<GroupApplyInfoResp.ItemsBean, BaseViewHolder> implements BaseQuickAdapter.OnItemClickListener {
    public ListAdapter() {
        super(R.layout.session_join_group_apply_info_item);
        setOnItemClickListener(this);
    }

    @Override
    protected void convert(BaseViewHolder helper, GroupApplyInfoResp.ItemsBean item) {
        TioImageView iv_avatar = helper.getView(R.id.iv_avatar);
        TextView tv_nick = helper.getView(R.id.tv_nick);

        iv_avatar.load_tioAvatar(item.getAvatar());
        tv_nick.setText(StringUtils.null2Length0(item.getNick()));
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        GroupApplyInfoResp.ItemsBean bean = getData().get(position);
        int uid = bean.getUid();
        if (mContext != null && uid != 0) {
            TioSession.getBridge().startUserDetailActivity(mContext, uid + "");
        }
    }
}
